package com.ejior.bluetea.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.ejior.bluetea.MainActivity;
import com.ejior.bluetea.R;
import com.ejior.bluetea.adapter.DeviceListAdapter;
import com.ejior.bluetea.bean.BLEDevice;

import java.util.ArrayList;
import java.util.List;


import static android.widget.LinearLayout.HORIZONTAL;

/**
 * Created by kevin on 2017/8/26.
 */

public class Tab2Fragment extends Fragment implements View.OnClickListener {

    private RecyclerView recyclerView;
    private Button btn_search;
    DeviceListAdapter adapter;

    private MainActivity mainActivity;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainActivity = (MainActivity) getActivity();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_tab2, container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        btn_search = (Button) view.findViewById(R.id.btn_search);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        btn_search.setOnClickListener(this);
        adapter = new DeviceListAdapter(mainActivity);
        recyclerView.setLayoutManager(new LinearLayoutManager(mainActivity));
        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), HORIZONTAL));
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {

    }
}
